package com.wanbangee.marksystem.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wanbangee.marksystem.entities.MClass;
import com.wanbangee.marksystem.entities.MExam;
import com.wanbangee.marksystem.entities.MSubject;
import com.wanbangee.marksystem.service.QueryCurrentExamService;

@CrossOrigin
@RestController
@RequestMapping("/all")
public class QueryCurrentExamController {

	@Autowired
	private QueryCurrentExamService queryCurrentExamService;
	
	@RequestMapping(value = "/allexams",method = RequestMethod.GET)
	public Map<String, Object> selectCurrentAllExams(@RequestParam("accId")Integer accId){
		Map<String, Object> map = new HashMap<>();
		List<MExam> examList =  this.queryCurrentExamService.selectCurrentAllExams(accId);
		map.put("examList", examList);
		return map;
	}
	
	@RequestMapping(value = "/allclasses",method = RequestMethod.GET)
	public Map<String, Object> selectAllClass(@RequestParam("examId")Integer examId){
		Map<String, Object> map = new HashMap<>();
		List<MClass> classList = this.queryCurrentExamService.selectAllExamClass(examId);
		map.put("classList", classList);
		return map;
	}
	
	@RequestMapping(value = "/allsubjects",method = RequestMethod.GET)
	public Map<String, Object> selectAllSubject(@RequestParam("examId")Integer examId){
		Map<String, Object> map = new HashMap<>();
		List<MSubject> subjectList = this.queryCurrentExamService.selectAllExamSubject(examId);
		map.put("subjectList", subjectList);
		return map;
	}
}
